#!/usr/bin/env python
#Basic Connection Example   - connect.py

import socket

print "Creating socket..."
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "Done."

print "Looking up port number..."
port = socket.getservbyname('http', 'tcp')
print 'done.'

print "Connecting to remoter host on port %d..." % port
s.connect(("www.baidu.com", port))
print "done."


print "Connected from ", s.getsockname()
print "Connected to ", s.getpeername()
